<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class News extends CI_Controller {

    function __construct(){
        parent::__construct();
        $this->load->model('news_model', 'n');
    }

    public function index(){
        $data['result'] = $this->n->get_many_by(array('delete_flag' => UNDELETE_FLAG, 'active_flag' => ACTIVE_FLAG, 'draft' => UNACTIVE_FLAG));
        $data['tpl']    = 'home/news/index';
        $this->load->view('_layout/index', $data);
    }

    function detail($id = 0){
        $data['data'] = $this->n->get_by(array('news_id' => $id));
        $data['more'] = $this->n->limit(10)->get_many_by(array('news_id !=' => $id, 'delete_flag' => UNDELETE_FLAG, 'draft' => UNACTIVE_FLAG));
        $data['tpl']    = 'home/news/detail';
        $this->load->view('_layout/index', $data);
    }
}